% rts file cmpression
% latest date 10.1.2003

% the difference & byte reduction seems to be no better
% ( some times worse) than program like winzip


[fid,er] = getbfile('*.rts');
[TS,fid] = rts_in(fid);
fclose(fid);
%fid = fopen('\\dell01\e\manoj\data\test1','wb');
Data = [TS.matrix(:,1)' TS.matrix(:,2)' TS.matrix(:,3)' TS.matrix(:,4)' TS.matrix(:,5)'];
clear TS;
s = length(Data);
DiffMatrix = Data(1:s-1)-Data(2:s);
%[count] = fwrite(fid,Data(1),'int16');
clear Data;

JJ = find(DiffMatrix <=2^7 & DiffMatrix >= -2^7); % represented by one byte
HH = find(DiffMatrix > 2^7 | DiffMatrix < -2^7 & DiffMatrix <= 2^15 & DiffMatrix >= -2^15);% represented by two bytes
KK = find(DiffMatrix > 2^15| DiffMatrix < -2^15);% represented by one byte

%fclose(fid);
      
ComRatio  = (length(JJ)+length(HH)*2+length(KK)*4)/(s*4);
fprintf('Total elements %d one byte %d two bytes %d four bytes %d ratio %f\n',s,length(JJ),length(HH),length(KK),ComRatio);
